import { ref } from 'vue'
import { defineStore } from 'pinia'

// KeepAlive仓储
export const keepAliveStore = defineStore('keepAlive', () => {

    //region # States

    // 包含列表
    const includes:Ref<Array<string>> = ref([])

    // 排除列表
    const excludes:Ref<Array<string>> = ref([])

    //endregion

    //region # Actions

    /**
     * 移除包含元素
     * @param componentName - 组件名称
     * */
    const removeInclude = function(componentName:string) {

        includes.value.splice(includes.value.indexOf(componentName), 1);
    }

    /**
     * 移除排除元素
     * @param componentName - 组件名称
     * */
    const removeExclude = function(componentName:string) {

        excludes.value.splice(excludes.value.indexOf(componentName), 1);
    }

    //endregion

    return {
        includes,
        excludes,
        removeInclude,
        removeExclude,
    }
})